//
//  BaseTableViewController.swift
//  weibo-anpeng
//
//  Created by 安鹏 on 16/1/11.
//  Copyright © 2016年 安鹏. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate {
    
    var userLogin = false
    var visitorLoginView: VisitorLoginView?
    
    // 苹果专为手写代码准备的类 一旦实现该方法 sb/xib会自动失效
    override func loadView() {
        if userLogin {
            super.loadView()
        } else {
            visitorLoginView = VisitorLoginView()
            visitorLoginView?.visitorViewDelegate = self
            view = visitorLoginView
            self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
            self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
        }
    }
    
    func userWillLogin() {
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func userWillRegister() {
        print(__FUNCTION__)
    }
    
    override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()
        
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }


}
